#include <stdio.h>
#include "aim.h"

void show(struct image * restrict out){
	for(int y = 0; y < out->rows; ++y){
		for(int x = 0; x < out->cols; ++x){
			bool p = image_getpixel(out, x, y);
			putchar(".#"[p]);
		}
		putchar('\n');
	}
	putchar('\n');
}

void
exercise(struct image * restrict in, struct image * restrict out)
{
	/* Do your image transformation here. Delete the code below
	 * first, especially when testing with large images! Modify
	 * the image, not just the printing code. */
	unsigned int *p =(unsigned int *) in->bitmap;
	unsigned int * q = (unsigned int *) out->bitmap;
	unsigned int steps = (in->cols * in->rows) / (sizeof(unsigned int) * 8);
	for(int i = 0; i < steps; ++i, ++p, ++q){
		*q = ~(*p);
	}

	show(in);
	putchar('\n');
	show(out);





	//for (int y = 0; y < in->rows; y++) {
	//	for (int x = 0; x < in->cols; x++) {
	//		bool p = image_getpixel(in, x, y);
	//		putchar(".#"[p]);
		        //image_putpixel(out, in->cols - x - 1, y, p);
//			image_putpixel(out
	//	}
		putchar('\n');
//	}
//    putchar('\n');

/*    for (int y = 0; y < in->rows; y++) {
        for (int x = 0; x < in->cols; x++) {
            bool p = image_getpixel(out, x, y);
            putchar(".#"[p]);
        }
        putchar('\n');
    }
*/
}



void
exercise0(struct image * restrict in, struct image * restrict out)
{
    /* Do your image transformation here. Delete the code below
     * first, especially when testing with large images! Modify
     * the image, not just the printing code. */
    for (int y = 0; y < in->rows; y++) {
        for (int x = 0; x < in->cols; x++) {
            bool p = image_getpixel(in, x, y);
            putchar(".#"[p]);
            image_putpixel(out, x, y, p);
        }
        putchar('\n');
    }
}
